/*
 * @Descripttion: 监听事件
 * @Version: 1.0
 * @Author: undead
 * @Date: 2021-04-23 10:46:02
 * @LastEditors: undead
 * @LastEditTime: 2021-04-25 21:43:51
 */

export default class NewEvent {
    constructor() {
        this.initEvent();
    }
    event = ["click"];
    initEvent() {
        this.event.forEach(e => {
            document.addEventListener(e, this.handle);
        });
    }
    handle(event: Event | any) {
        const path = event.composedPath && event.composedPath();
        const outerHTML = event.target.outerHTML;
        const tagName = [];
        path.forEach((el: { tagName: string; }) => {
            el.tagName && tagName.push(el.tagName);
        });
        console.log(tagName, outerHTML);
    }
}
